home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
PROGRAMMING
/
LCLINT2.SPK
/
docs
/
ROS-txt
< prev
Wrap
Text File
|
1996-11-15
|
10KB
|
233 lines
LCLint 2.2a+
RISC OS port version 0.01
LCLint is a tool for statically checking C source code prior to compilation.
Full details on the use of LCLint can be found in the User's Guide. This
should be available, in HTML and plain text format, from the same place that
this archive came from or from the LCLint Home page:-
http://larch-www.lcs.mit.edu:8001/larch/lclint/
This file is designed to document any changes that were necessary to port
LCLint to RISC OS.
Filenames
---------
Standard RISC OS filenames are expected, although some filename processing is
carried out to allow similar naming conventions to the C compiler. Therefore,
where MSDOS style extensions are used, they are converted to directory names.
For example, a file named:-
abstract.c
with be converted to:-
c.abstract
The c extension is converted to a directory called c as is normal for RISC
OS. This is also true if any pathname is given, so the names:-
sources.abstract.c
sources:abstract.lcl
will be converted to:-
sources.c.abstract
sources:lcl.abstract
respectively before being passed to the filing system.
The above filename processing applies to c, h and lcl files only. It may be
extended to other filetypes in a later release if this is found to be useful.
Installation of LCLint
----------------------
Before attempting to use LCLint, all files within the archive should be
extracted to an empty directory on a hard disc. This document will assume
that the directory is called lclint. This directory should then contain:-
lclint = the installation directory
|
|-!Setup = Obey file for run path and system variables
|
|-lclintrc = options file (can be altered as required)
|
|-lclint = the executable
|
|-imports = directory containing standard library files
|
|-lib = directory containing standard lclint library files
|
|-test = directory containing test suite
|
|-docs = directory containing User's guide as a text file
and this file in ASCII and EasiWriter format
Using LCLint under RISC OS
--------------------------
Double-clicking the obey file called !Setup will place LCLint on the run path
so that it can be found easily. !Setup also creates three system variables
that LCLint requires, which are closely modelled on the original ones used in
the Unix environment. They are:-
Larch$PathDir
LCLint$ImportDir - these define the path names of the LCLint standard
libraries
LCLint$CPPCmd - this defines the command used to invoke the C
preprocessor. This can be changed to use a different
preprocessor such as gcc or perhaps decus-cpp (the
latter however has not been tested).
Please note that if any changes are made to this obey file, they will not be
implemented unless the file is double-clicked again.
LCLint can be used from a makefile as shown by the test suite in this
distribution.
Alternatively, it is recommended that it be run within a taskwindow where the
results can be caught and saved if necessary. The taskwindow should be
allocated enough memory to run both LCLint and the C preprocessor at the same
time not forgetting to allow for the data they will process. It should be
noted that the unsqueezed size of LCLint is currently 1054K. I have found
that most of the test suite source code needs 3MB, but the database examples
need about 5MB. The Currently Selected Directory (CSD) should be set to the
one that contains the c and h directories. This can easily be done by
typing:-
dir<SPACE>
in the taskwindow and then shift-dragging the relevant directory to the
taskwindow where the full pathname of the directory will be inserted after
the dir command. Pressing RETURN will then execute the command.
If the switch -nof is NOT given on the command line, then additional options
are read from the file named lclintrc in the home directory of LCLint.
Additional switches
-------------------
In addition to the switches described in the User's Guide, this port of
LCLint also provides -throwback (on command line only) which enables the
transfer of errors messages to a text editor. The ddeutils modules is
required for the use of this facility.
Trouble-shooting
----------------
If LCLint complains that it is unable to open a temp file, then ensure that
the compiler is visible on the command, i.e. that it is in the run path or
in the library directory. For example, GCC requires that you double-click on
!GCC, but be aware that this resets the CSD. If the compiler is not on the
same filing system as your work directory, then alter LCLint$CPPcmd to add
the filing system to the beginning of the command, e.g. adfs:cc -E. Also
ensure, if the compiler is not being called, that there is enough memory for
it to be loaded.
If your source code #includes library headers, make sure that you use the -I
switch so that LCLint can tell the preprocessor where it can find them.
If the compiler complains about not being able to find a standard header file
, make sure that C: has been defined.
Known problems
--------------
A parse error is generated when parsing the Acorn C standard headers
preprocessed with Acorn C/C++. This seems to be caused by the line #pragma
force_top_level. There are two ways to overcome this, either use the
+trytorecover switch or alter the header files so that the #pragma is defined
out when LCLint is in use, i.e.
#ifndef __LCLINT__
#pragma force_top_level
#endif
The __LCLINT__ macro is automatically defined and passed to the
preprocessor by LCLint. The problem does not exist when GCC is used as the
preprocessor as it does not expand the Acorn C/C++ #pragmas.
The use of the hash character (#) on the command line causes problems.
Specifically the command line seems to be truncated at the hash character
before being passed to LCLint. Because of this, the two targets in the test
suite that depend on this will fail. These are commentchar and prefixes. The
use of the hash character in an rc file is unaffected.
Temporary files are not always deleted from the scrap directory. This is an
isolated problem caused by a file being opened and not closed properly.
Although all files that were opened by a particular incarnation of LCLint are
closed by it on it's exit, this occurs after LCLint attempts to delete it and
so the deletion fails.
When using Acorn C/C++ as the preprocessor, errors in c files are usually
reported one line greater than where they really are. Header files do not
seem to be affected by this. This is somehow caused by the #line directives
generated by Acorn C/C++ in the preprocessed output either having the wrong
line numbers or being on the wrong line. I did try to fix this in LCLint by
testing for Acorn C/C++ and adjusting the line numbers whenever a #line
directive was encountered, but only had partial success. I decided it was
better to be consistently wrong rather than sometimes right.
Notes about the test suite
--------------------------
The directory structure of the test suite in this distribution is slightly
different to the original due to the limit of 77 files per directory imposed
by RISC OS. This mainly affects the c directory holding the source files. As
a result of this it was necessary to split the test directory into two,
test_a and test_b, so that two c directories could exist to hold the source
files. This has meant that there is some duplication in the files (but not a
lot) and that the makefiles have had to be altered to take the different
directory structure into account.
Also due to a RISC OS limitation, some of the longer filenames have been
truncated to ten characters, but in practice should still be recognisable.
Assuming that AMU and make have been seen by the filer and !Setup has been
double-clicked to place lclint on your run path, the tests can be executed by
typing the following:-
dir <path>.lclint.test
amu
where <path> is the pathname of the directory where the lclint directory is
stored. If using a taskwindow (which is recommended) then the test directory
can be shift-dragged to it. The command amu executes the makefile in this
directory which automatically executes makefiles for test_a, db1, db2, db3
(which are all in test_a), test_b and tests2_2 (which is in test_b).
Issuing the command:-
amu clean
will delete all files and directories that were created during execution of
the above make files.
The first and third tests of the rc target in test_b.makefile fail because of
two odd macros.
When executing the makefile for any of the three database examples, db1, db2
or db3, creation of the LCS file for dbase.c more often than not generates a
free() failed error. This does not affect the creation of the file and
execution of the makefile will continue unaffected.
When checking db3, lots of errors may be generated for the standard library
headers especially for Acorn C/C++. This is because db3 is checked using the
+strict flag which forces LCLint to use a stricter version of it's standard
library. This version of the LCLint standard library does not match up with
the header files for Acorn C/C++, hence the extra code errors. These can be
ignored.
A note about the HTML format User's Guide
-----------------------------------------
Due to the number of files that make up the HTML User's Guide and the length
of the filenames, it is not practical to extract it from it's archive. It is
therefore recommended that it is used whilst still archived.
Finally
-------
Please report any bugs or other problems to me at the Email address below.
If an error occurs that requests that you report it to
lclint-bug@larch.lcs.mit.edu, please report it to me first in case it is
specific to the RISC OS version. Also please ensure that they are not the
result of low memory or a missing compiler.
Lee Noar
leenoar@argonet.co.uk